//
// Created by 紫霄 on 2020/4/11.
//

#ifndef LEETCODE_13_H
#define LEETCODE_13_H
#include <cstdint>
class Solution {
public:
  int hammingWeight(uint32_t n) {
    int m = 0; //余数；
    int cnt = 0;
    while (n) {
      m = n % 2;
      if (m == 1) {
        ++cnt;
      }
      n = n / 2;
    }
    return cnt;
  }
};
#endif // LEETCODE_13_H
